package spring.JUNIT.bean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;

@Configuration
@ImportResource("D:/spring/spring-Annotation.xml")
public class StoreConfig {

	@Bean(name = "store", initMethod = "init", destroyMethod = "destroy")
	public Store<String> stringStore() {
		return new StringStore();
	}

	@Bean(name = "store2")
	public Store<Integer> integerStore() {
		return new IntegerStore();
	}

	@Value("${url}")
	private String url;

	@Value("${jdbc.username}")
	private String username;

	@Value("${password}")
	private String password;

	@Bean
	@Scope(value = "prototype", proxyMode = ScopedProxyMode.TARGET_CLASS)
	public MyDriverManager myDriverManager() {
		return new MyDriverManager(url, username, password);
	}

}
